Abort after representability errors#153317
Conversation
|
|
|
This overlaps with #153028 by @Zoxc. (I wrote this independently a few days ago after writing #153169 and then subsequently discovered the overlap.) That PR changes the |
This comment has been minimized.
This comment has been minimized.
44bc328 to
8675222
Compare
Turns out this doesn't work for the reason because it requires dropping |
| Representable, | ||
| Infinite(ErrorGuaranteed), | ||
| } | ||
| pub struct Representability; |
There was a problem hiding this comment.
I like that you haven't got rid of this type, although I would have made it pub struct Representability(()) in order to make its construction a private detail for a query implementation.
There was a problem hiding this comment.
Hmm, but we cannot do that as query implementation is in another crate. I guess I would've done new_unchecked unsafe fn instead then if rustc was my project, but that's kinda a far too theoretical concern for an open project.
The second commit message still mentions ensure_ok and anon |
Currently, `Representability::from_cycle_error` prints an "infinite size" error and then returns `Representability::Infinite`, which lets analysis continue. This commit changes it so it just aborts after printing the error. This has two benefits. First, the error messages are better. The error messages we get after continuing are mostly bad -- we usually get another cycle error, e.g. about drop checking or layout, which is not much use to the user, and then abort after that. The only exception is `issue-105231.rs` where a "conflicting implementations" error is now omitted, but there are three other errors before that one so it's no great loss. Second, it allows some simplifications: see the next commit.
This variant was a fallback value used to continue analysis after a `Representability` error, but it's no longer needed thanks to the previous commit. This means `Representability` can now be reduced to a unit type that exists just so `FromCycleError` can exist for the `representability` query. (There is potential for additional cleanups here, but those are beyond the scope of this PR.) This means the `representability`/`representability_adt_ty` queries no longer have a meaningful return value, i.e. they are check-only queries. So they now have a `check_` prefix added. And the `rtry!` macro is no longer needed.
8675222 to
ff3d308
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
I have rebased and removed the |
| Representable, | ||
| Infinite(ErrorGuaranteed), | ||
| } | ||
| pub struct Representability; |
There was a problem hiding this comment.
if you want to keep enforcing let _ = in front of the query invocations, then this struct should be #[must_use]. Otherwise just call the query like we call unit queries
There was a problem hiding this comment.
If I change this:
let _ = tcx.check_representability(item.owner_id.def_id);to this:
tcx.check_representability(item.owner_id.def_id);I get this warning:
warning: unused return value of `queries::<impl rustc_middle::ty::TyCtxt<'tcx>>::check_representability` that must be used
--> compiler/rustc_hir_analysis/src/check/wfcheck.rs:1000:5
|
1000 | tcx.check_representability(item.owner_id.def_id);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default
help: use `let _ = ...` to ignore the resulting value
|
1000 | let _ = tcx.check_representability(item.owner_id.def_id);
| +++++++
I'm not sure where the must_use that triggers this comes from.
I could instead do this:
tcx.ensure_ok().check_representability(item.owner_id.def_id);which is probably better, given that ensure_ok can help with incremental perf. Sound ok to you?
There was a problem hiding this comment.
Oh, I totally goldfished that I tried ensure_ok before.
Anyway, I don't see how to avoid the let _ = things, given that I get the warnings without them.
There was a problem hiding this comment.
Right. Unfortunate but makes sense for now
|
@bors r+ |
…rrors, r=oli-obk Abort after `representability` errors Doing so results in better error messages and makes the code a bit simpler. Details in individual commits. r? @oli-obk
…rrors, r=oli-obk Abort after `representability` errors Doing so results in better error messages and makes the code a bit simpler. Details in individual commits. r? @oli-obk
…rrors, r=oli-obk Abort after `representability` errors Doing so results in better error messages and makes the code a bit simpler. Details in individual commits. r? @oli-obk
…rrors, r=oli-obk Abort after `representability` errors Doing so results in better error messages and makes the code a bit simpler. Details in individual commits. r? @oli-obk
Rollup of 9 pull requests Successful merges: - #152164 (Lint unused features) - #152801 (Refactor WriteBackendMethods a bit) - #153317 (Abort after `representability` errors) - #153361 (enable `PassMode::Indirect { on_stack: true, .. }` tail call arguments) - #153402 (miri subtree update) - #153276 (Remove `cycle_fatal` query modifier) - #153396 (use `minicore` in some `run-make` tests) - #153401 (Migrationg of `LintDiagnostic` - part 7) - #153406 (Remove a ping for myself)
Rollup of 9 pull requests Successful merges: - #152164 (Lint unused features) - #152801 (Refactor WriteBackendMethods a bit) - #153317 (Abort after `representability` errors) - #153361 (enable `PassMode::Indirect { on_stack: true, .. }` tail call arguments) - #153402 (miri subtree update) - #153276 (Remove `cycle_fatal` query modifier) - #153396 (use `minicore` in some `run-make` tests) - #153401 (Migrationg of `LintDiagnostic` - part 7) - #153406 (Remove a ping for myself)
…uwer Rollup of 12 pull requests Successful merges: - #153402 (miri subtree update) - #152164 (Lint unused features) - #152801 (Refactor WriteBackendMethods a bit) - #153196 (Update path separators to be available in const context) - #153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors) - #153317 (Abort after `representability` errors) - #153276 (Remove `cycle_fatal` query modifier) - #153300 (Tweak some of our internal `#[rustc_*]` TEST attributes) - #153396 (use `minicore` in some `run-make` tests) - #153401 (Migrationg of `LintDiagnostic` - part 7) - #153406 (Remove a ping for myself) - #153414 (Rename translation -> formatting)
…uwer Rollup of 12 pull requests Successful merges: - #153402 (miri subtree update) - #152164 (Lint unused features) - #152801 (Refactor WriteBackendMethods a bit) - #153196 (Update path separators to be available in const context) - #153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors) - #153317 (Abort after `representability` errors) - #153276 (Remove `cycle_fatal` query modifier) - #153300 (Tweak some of our internal `#[rustc_*]` TEST attributes) - #153396 (use `minicore` in some `run-make` tests) - #153401 (Migrationg of `LintDiagnostic` - part 7) - #153406 (Remove a ping for myself) - #153414 (Rename translation -> formatting)
…uwer Rollup of 12 pull requests Successful merges: - #153402 (miri subtree update) - #152164 (Lint unused features) - #152801 (Refactor WriteBackendMethods a bit) - #153196 (Update path separators to be available in const context) - #153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors) - #153317 (Abort after `representability` errors) - #153276 (Remove `cycle_fatal` query modifier) - #153300 (Tweak some of our internal `#[rustc_*]` TEST attributes) - #153396 (use `minicore` in some `run-make` tests) - #153401 (Migrationg of `LintDiagnostic` - part 7) - #153406 (Remove a ping for myself) - #153414 (Rename translation -> formatting)
…uwer Rollup of 12 pull requests Successful merges: - #153402 (miri subtree update) - #152164 (Lint unused features) - #152801 (Refactor WriteBackendMethods a bit) - #153196 (Update path separators to be available in const context) - #153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors) - #153317 (Abort after `representability` errors) - #153276 (Remove `cycle_fatal` query modifier) - #153300 (Tweak some of our internal `#[rustc_*]` TEST attributes) - #153396 (use `minicore` in some `run-make` tests) - #153401 (Migrationg of `LintDiagnostic` - part 7) - #153406 (Remove a ping for myself) - #153414 (Rename translation -> formatting)
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#153402 (miri subtree update) - rust-lang/rust#152164 (Lint unused features) - rust-lang/rust#152801 (Refactor WriteBackendMethods a bit) - rust-lang/rust#153196 (Update path separators to be available in const context) - rust-lang/rust#153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors) - rust-lang/rust#153317 (Abort after `representability` errors) - rust-lang/rust#153276 (Remove `cycle_fatal` query modifier) - rust-lang/rust#153300 (Tweak some of our internal `#[rustc_*]` TEST attributes) - rust-lang/rust#153396 (use `minicore` in some `run-make` tests) - rust-lang/rust#153401 (Migrationg of `LintDiagnostic` - part 7) - rust-lang/rust#153406 (Remove a ping for myself) - rust-lang/rust#153414 (Rename translation -> formatting)
…uwer Rollup of 12 pull requests Successful merges: - rust-lang/rust#153402 (miri subtree update) - rust-lang/rust#152164 (Lint unused features) - rust-lang/rust#152801 (Refactor WriteBackendMethods a bit) - rust-lang/rust#153196 (Update path separators to be available in const context) - rust-lang/rust#153204 (Add `#[must_use]` attribute to `HashMap` and `HashSet` constructors) - rust-lang/rust#153317 (Abort after `representability` errors) - rust-lang/rust#153276 (Remove `cycle_fatal` query modifier) - rust-lang/rust#153300 (Tweak some of our internal `#[rustc_*]` TEST attributes) - rust-lang/rust#153396 (use `minicore` in some `run-make` tests) - rust-lang/rust#153401 (Migrationg of `LintDiagnostic` - part 7) - rust-lang/rust#153406 (Remove a ping for myself) - rust-lang/rust#153414 (Rename translation -> formatting)
Doing so results in better error messages and makes the code a bit simpler. Details in individual commits.
r? @oli-obk